home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Loadstar 41
/
041.d81
/
snag source
(
.txt
)
< prev
next >
Wrap
Commodore BASIC
|
2022-08-26
|
21KB
|
779 lines
1000 sys700:.opt oo
1010 *=$c000
1020 ;
1030 ;********************************
1040 ;* *
1050 ;* snag 1.0 *
1060 ;* *
1070 ;* copyright 1987 by nick peck *
1080 ;* *
1090 ;********************************
1100 ;
1110 nmioff =$fec1 ;restore is off here
1120 stuff =$f000 ;mem. for snag stack
1130 string =$ab1e ;display a string
1140 getin =$ffe4 ;get a keyboard byte
1150 chrout =$ffd2 ;output a byte
1160 chrin =$ffcf ;64's input routine
1170 plot =$fff0 ;plot 64's cursor
1180 close =$ffc3 ;close a file
1190 clall =$ffe7 ;close all files
1200 open =$ffc0 ;open a file
1210 setnam =$ffbd ;set file name
1220 setlfs =$ffba ;set file status
1230 talk =$ffb4 ;make device talk
1240 tksa =$ff96 ;talk second address
1250 chkout =$ffc9 ;open output channel
1260 untlk =$ffab ;make device untalk
1270 acptr =$ffa5 ;serial port get
1280 cursco =$0286 ;64's cursor color
1290 scnlin =$0748 ;start of menu
1300 txtlin =$0770 ;start of text line
1310 collin =$db48 ;menu color memory
1320 a =$02 ;temps used everywhere
1330 b =$03 ; '' ''
1340 xtemp =$04 ; '' ''
1350 ytemp =$05 ; '' ''
1360 blockx =$fd ;position of block
1370 blocky =$fe ; '' ''
1380 xpos =$fb ;position of cursor
1390 ypos =$fc ; '' ''
1400 lowpnt =$06 ;low-high used in plot
1410 highpt =$07 ; '' ''
1420 collow =$22 ;used to get old color
1430 colhii =$23 ; '' ''
1440 oldcol =$24 ;flag- use old color
1450 addmov =$25 ;flag- right or down
1460 xptemp =$4b ;temp for make block
1470 yptemp =$4c ; '' ''
1480 xbtemp =$4d ; '' ''
1490 ybtemp =$4e ; '' ''
1500 flpplt =$4f ;flag- plot y,x *(x,y)
1510 output =$50 ;flag- output unblock
1520 lastch =$51 ;temp for unblock
1530 choice =$52 ;append choice (y/n)
1540 curcol =$53 ;current snag color
1550 qtmode =$d4 ;64 quote mode on/off
1560 ;
1570 ;the following code copies the
1580 ;stack and zero page so that snag
1590 ;has it's own stack and zero page
1600 ;when entered via the hardware irq
1610 ;
1620 intstr lda #"n" ;start append
1630 sta choice ;choice as 'n
1640 lda #"/"
1650 sta fname ;start file
1660 lda #"," ;name as '/'
1670 sta fname+1
1680 sei
1690 lda #>rthere ;set return
1700 pha ;address for
1710 lda #<rthere-1 ;flip stack
1720 pha ;routine.
1730 tsx ;save stack
1740 stx stktmp ;pointer
1750 lda #0
1760 sta $fb ;copy first
1770 sta $fc ;4 blocks of
1780 lda #<stuff ;memory
1790 sta $fd
1800 lda #>stuff
1810 sta $fe
1820 ldx #4
1830 ldy #2
1840 mrtoit lda ($fb),y
1850 sta ($fd),y
1860 iny
1870 bne mrtoit
1880 inc $fc
1890 inc $fe
1900 dex
1910 bne mrtoit
1920 lda #<nmioff ;snag vectors
1930 sta $0318 ;snag restore
1940 lda #>nmioff ;is disabled
1950 sta $0319
1960 lda #<extsng ;brk vector
1970 sta $0316 ;is used to
1980 lda #>extsng ;exit snag
1990 sta $0317
2000 lda #>start ;new pch
2010 pha
2020 lda #<start ;new pcl
2030 pha
2040 lda #0 ;status
2050 pha
2060 pha ;.a
2070 pha ;.x
2080 pha ;.y
2090 lda #>rthre2 ;set return
2100 pha ;address for
2110 lda #<rthre2-1 ;next flip
2120 pha ;stack call
2130 jmp flipmm ;flip stacks
2140 rthere lda #<baserr ;change basics
2150 sta $0300 ;error message
2160 lda #>baserr ;vector to
2170 sta $0301 ;reset irq
2180 cli
2190 lda #96 ;put an rts
2200 sta intstr ;in first byte
2210 rts
2220 ;
2230 ;every time basic prints an error
2240 ;or a 'ready' the irq vector is
2250 ;set to snag
2260 ;
2270 baserr sei
2280 ldy #<(NULL)ther ;new irq that
2290 sty $0314 ;looks for a
2300 ldy #>(NULL)ther ;ctrl-f3
2310 sty $0315
2320 cli
2330 jmp $e38b
2340 ;
2350 ;the irq comes here to look for
2360 ;a ctrl-f3
2370 ;
2380 (NULL)ther lda $c5 ;look for f3
2390 cmp #5
2400 beq yesf3
2410 outirq jmp $ea31
2420 yesf3 lda $028d ;look for ctrl
2430 cmp #4
2440 bne outirq
2450 lda #>retext
2460 pha
2470 lda #<retext-1
2480 pha
2490 jmp flipmm ;flip stacks
2500 rthre2 jmp $ea31
2510 ;
2520 extsng lda #>rthre2
2530 pha
2540 lda #<rthre2-1
2550 pha
2560 jmp flipmm ;flip stacks
2570 retext jmp $ea31
2580 ;
2590 ;this routine flips the stack
2600 ;memory with a modified stack
2610 ;in memory without using
2620 ;zero page
2630 ;
2640 flipmm lda #<stuff
2650 sta top+1 ;source low
2660 sta stuff2+1
2670 lda #>stuff
2680 sta top+2 ;source high
2690 sta stuff2+2
2700 lda #0
2710 sta stuff1+1 ;target low
2720 sta stuff3+1
2730 sta stuff1+2 ;target high
2740 sta stuff3+2
2750 ldy #4
2760 ldx #2
2770 toplop lda #52 ;off basic
2780 sta $01
2790 top lda $ffff,x ;source
2800 sta tmpbyt
2810 lda #55 ;on basic
2820 sta $01
2830 stuff1 lda $ffff,x ;target
2840 stuff2 sta $ffff,x ;source
2850 lda tmpbyt
2860 stuff3 sta $ffff,x ;target
2870 inx
2880 bne toplop
2890 inc top+2
2900 inc stuff1+2
2910 inc stuff2+2
2920 inc stuff3+2
2930 dey
2940 bne toplop
2950 lda stktmp ;flip stack
2960 tsx ;pointers
2970 stx stktmp
2980 tax
2990 txs
3000 rts
3010 ;
3020 start ldy #0 ;actual start
3030 sty xpos ;of snag code
3040 lda #216
3050 sta ypos
3060 lda #<color ;make a copy
3070 sta blockx ;of screen
3080 lda #>color ;color
3090 sta blocky
3100 ldx #4
3110 trans lda (xpos),y
3120 sta (blockx),y
3130 iny
3140 bne trans
3150 inc ypos
3160 inc blocky
3170 dex
3180 bne trans ;set snag cur-
3190 lda 53281 ;sor color
3200 and #15 ;according to
3210 tax ;table
3220 lda colors,x
3230 sta curcol
3240 ldx #255 ;disable block
3250 stx blockx ;with two ff's
3260 stx blocky
3270 inx
3280 stx oldcol ;1 = old color
3290 stx addmov ;1 = add x or y
3300 stx flpplt ;1 = y,x not x,y
3310 stx output ;1 = disk/printr
3320 stx xpos ;cursor x and y
3330 stx ypos
3340 txa
3350 tay ;plot initial
3360 jsr revers ;cursor
3370 getmor jsr getin
3380 beq getmor
3390 cmp #"[133]" ;is it an f1
3400 bne nostop
3410 jsr unblck ;yes, shut off
3420 ldx xpos ;block, erase
3430 ldy ypos ;cursor and exit
3440 inc oldcol ;according to
3450 jsr revers ;the brk vector
3460 brk
3470 nop:nop:nop ;pc returns
3480 jmp start ;here
3490 nostop cmp #"" ;cursor right
3500 bne notrit
3510 ldx xpos
3520 cpx #39
3530 beq notrit
3540 inc addmov ;set add flag
3550 jsr xblock ;move right
3560 dec addmov ;unset add flag
3570 notrit cmp #"[157]" ;cursor left
3580 bne notlft
3590 ldx xpos
3600 beq notlft
3610 inc oldcol ;set color flag
3620 jsr xblock ;move left
3630 dec oldcol ;unset col flag
3640 notlft cmp #"" ;cursor down
3650 bne notdwn
3660 ldx ypos
3670 cpx #24
3680 beq notdwn
3690 inc addmov ;set add flag
3700 jsr yblock ;move down
3710 dec addmov ;unset add flag
3720 notdwn cmp #"[145]" ;cursor up
3730 bne notup
3740 ldx ypos
3750 beq notup
3760 inc oldcol ;set color flag
3770 jsr yblock ;m